package edu.nf.relaxenjoy.web.controller.app;

import edu.nf.relaxenjoy.common.result.ResultVO;
import edu.nf.relaxenjoy.common.validator.ValidatorUtils;
import edu.nf.relaxenjoy.common.validator.group.DefaultGroup;
import edu.nf.relaxenjoy.domain.dto.AlbumRelationDTO;
import edu.nf.relaxenjoy.service.AlbumRelationService;
import edu.nf.relaxenjoy.web.controller.BaseController;
import io.swagger.annotations.Api;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author zhu
 * @date 2024-12-20
 */
@RestController
@RequiredArgsConstructor
@RequestMapping("/api/albumRelation")
@Api(tags="专辑图片联系模块")
public class AlbumRelationController extends BaseController {

    private final AlbumRelationService albumRelationService;

    /**
     * 增加联系
     *
     * @param albumRelationDTO
     * @return
     */
    @RequestMapping("addAlbumRelation")
    public ResultVO addAlbumRelation(@RequestBody AlbumRelationDTO albumRelationDTO) {
        ValidatorUtils.validateEntity(albumRelationDTO, DefaultGroup.class);
        albumRelationService.addAlbumRelation(albumRelationDTO);
        return success();
    }

    /**
     * 当前用户是否已经收藏图片至专辑中
     *
     * @return
     */
    @RequestMapping("isCollectToAlbum")
    public ResultVO isCollectToAlbum(String uid, String mid) {
        boolean flag = albumRelationService.isCollectPostToAlbum(uid, mid);
        return success(flag);
    }


    /**
     * 删除关系
     *
     * @param albumRelationDTO
     * @return
     */
    @RequestMapping("deleteAlbumRelation")
    public ResultVO deleteAlbumRelation(@RequestBody AlbumRelationDTO albumRelationDTO) {
        ValidatorUtils.validateEntity(albumRelationDTO, DefaultGroup.class);
        albumRelationService.deleteAlbumRelation(albumRelationDTO);
        return success();
    }
}
